<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Detection demos">
    <meta name="author" content="fyk@xidian">

    <title>F22 Det</title>

    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">

    <script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.js"></script>
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

    <!-- Script to instantly classify an image once it is uploaded. -->
    <script type="text/javascript">
      $(document).ready(
        function(){
          $('#classifyfile').attr('disabled',true);
          $('#imagefile').change(
            function(){
              if ($(this).val()){
                $('#formupload').submit();
              }
            }
          );
        }
      );
    </script>

    <style>
    body {
      font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      line-height:1.5em;
      color: #232323;
      -webkit-font-smoothing: antialiased;
    }

    h1, h2, h3 {
      font-family: Times, serif;
      line-height:1.5em;
      border-bottom: 1px solid #ccc;
    }
    </style>
  </head>

  <body>
    <!-- Begin page content -->
    <div class="container">
      <div class="page-header">
        <h1><a href="/">目标检测识别 - 计算机视觉</a></h1>
        <p>
          <!--<h3>用于<b>123</b>目标检测</h3>-->
          <a href="https://github.com/makefile/objdet_web">
          康行天下
          </a>
        </p>
      </div>

      <div>
        <h2>检 测</h2>
        <!--<h2>记得改成GPU</h2>-->
        <!--cat image: http://i.telegraph.co.uk/multimedia/archive/02351/cross-eyed-cat_2351472k.jpg-->
        <a href="/classify_url?imageurl=http://img.jj20.com/up/allimg/311/042211021229/110422021229-11.jpg">
          点击这里快速示例
        </a>
      </div>

      {% if has_result %}
      {% if not result[0] %}
      <!-- we have error in the result. -->
      <div class="alert alert-danger">{{ result[1] }} </div>
      <div class="media">
          <a class="pull-left" href="#"><img class="media-object" width="512" height="512" src={{ imagesrc }}></a>
          <div class="media-body">
            <div class="bs-example bs-example-tabs">
              <ul id="myTab2" class="nav nav-tabs">
                <li class="active"><a href="#infopred" data-toggle="tab">预测结果</a></li>
                <!--<li><a href="#flatpred" data-toggle="tab">Maximally specific</a></li>-->
              </ul>
            </div>

          </div>
        </div>
      {% else %}
      <div class="media">
        <a class="pull-left" href="#"><img class="media-object" width="512" height="512" src={{ imagesrc }}></a>
        <div class="media-body">
          <div class="bs-example bs-example-tabs">
            <ul id="myTab" class="nav nav-tabs">
              <li class="active"><a href="#infopred" data-toggle="tab">预测结果</a></li>
              <!--<li><a href="#flatpred" data-toggle="tab">Maximally specific</a></li>-->
            </ul>
            <div id="myTabContent" class="tab-content">
              <div class="tab-pane fade in active" id="infopred">
                <ul class="list-group">
                  {% for single_pred in result[2] %}
                  <li class="list-group-item">
                  <span class="badge">{{ single_pred[1] }}</span>
                  <h4 class="list-group-item-heading">
                    <!--<a href="https://www.google.com/#q={{ single_pred[0] }}" target="_blank">{{ single_pred[0] }}</a>-->
                    <a>{{ single_pred[0] }}</a>
                  </h4>
                  </li>
                  {% endfor %}
                </ul>
              </div>
              <!--<div class="tab-pane fade" id="flatpred">
                <ul class="list-group">
                  {% if result[1] %}
                  {% for single_pred in result[1] %}
                  <li class="list-group-item">
                  <span class="badge">{{ single_pred[1] }}</span>
                  <h4 class="list-group-item-heading">
                    <a href="https://www.google.com/#q={{ single_pred[0] }}" target="_blank">{{ single_pred[0] }}</a>
                  </h4>
                  </li>
                  {% endfor %}
                  {% endif %}
                </ul>
              </div>-->
            </div>
          </div>
          <p> 耗时 {{ result[3] }} 秒. </p>
        </div>
      </div>

      {% endif %}

      {% endif %}
      <hr>
      <form role="form" action="classify_url" method="get">
        <div class="form-group">
          <div class="input-group">
            <input type="text" class="form-control" name="imageurl" id="imageurl" placeholder="输入图片网址 URL">
            <span class="input-group-btn">
              <input class="btn btn-primary" value="检测 URL" type="submit" id="classifyurl"></input>
            </span>
          </div><!-- /input-group -->
        </div>
      </form>

      <form id="formupload" class="form-inline" role="form" action="classify_upload" method="post" enctype="multipart/form-data">
        <div class="form-group">
          <label for="imagefile">或者上传图片:</label>
          <input type="file" name="imagefile" id="imagefile">
        </div>
        <!--<input type="submit" class="btn btn-primary" value="Classify File" id="classifyfile"></input>-->
      </form>
    </div>

    <hr>
    <div id="footer">
      <div class="container">
        <p>&copy; XDLab 2017</p>
      </div>
   </div>
 </body>
</html>
